<template>
  <div style="padding:0.8rem">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{path:'/'}">首页</el-breadcrumb-item>
      <el-breadcrumb-item v-for="list in breadList" :key="list.name">{{list.name}}</el-breadcrumb-item>
    </el-breadcrumb>
  </div>
</template>
<style>


</style>
<script>
import Bus from "../Bus.js"
export default {
  data() {
    return {
      breadList:[],
      menus:[
        {
          id:1,
          name:'工作平台',
          path:'/home'
        },
        {
          id:2,
          name:'用户管理',
          path:'/customer',
          children:[
            {
              id:21,
              name:'用户列表',
              path:'/user'
            },
            {
              id:22,
              name:'测试',
              path:'/test'
            },
            {
              id:23,
              name:'时间表',
              path:'/time'
            }
          ]
        },
        {
          id:3,
          name:'人物管理',
          path:'/center',
          children:[
            {
              id:31,
              name:'个人中心',
              path:'/person',
            },
            {
              id:32,
              name:'用户权限',
              path:'/limit',
            }
          ]
        }
      ]
    }
  },
  methods:{
    getLists(){
      Bus.$on('paths',(res)=>{
      this.breadList=[];
      let menuList = this.menus
      res.indexPath.map(item => {
        for (let i = 0; i < menuList.length; i++) {
          if (item === menuList[i].path) {
            this.breadList.push(menuList[i])
            if (menuList[i].children) {
              menuList = menuList[i].children
            }
            break;
          }
        }
      })
      
    })
    }  
  },
  mounted(){
    this.getLists();
  }
}
</script>
<style>
  
</style>